#include "LightComp.h"
#include <SECore/Ecs/Actor.h>


namespace SEngine
{

    void PointLightComp::Attach()
    {
        m_actor.Subscribe<PointLightComp, glm::mat4&>("SignalUpdateTransform", [this](glm::mat4 & model) {
            this->light.SetPos(model * glm::vec4{glm::vec3{0.0f}, 1.0f});
            return SlotState::Keep;
        });
    }

    void DirectLightComp::Attach()
    {
        m_actor.Subscribe<DirectLightComp, glm::mat4&>("SignalUpdateTransform", [this](glm::mat4 & model) {
            this->light.SetDirect(model * glm::vec4(1.0f, 0.0f, 0.0f, 0.0f));
            return SlotState::Keep;
        });
    }

    void AmbientLightSphereComp::Attach()
    {
        m_actor.Subscribe<AmbientLightSphereComp, glm::mat4&>("SignalUpdateTransform", [this](glm::mat4 & model) {
            this->light.SetPos(model * glm::vec4{glm::vec3{0.0f}, 1.0f});
            return SlotState::Keep;
        });
    }

} // namespace SEngine
